import 'package:json_annotation/json_annotation.dart';
part 'result.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class Result<T> {
  int? code;
  T? data;
  String? msg;
  String? method;
  String? result;
  Token? token;

  Result(
      {required this.code,
      this.data,
      this.msg,
      this.method,
      this.result,
      this.token});

  factory Result.fromJson(
    Map<String, dynamic> json,
    T Function(dynamic json) fromJsonT,
  ) =>
      _$ResultFromJson(json, fromJsonT);

  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) =>
      _$ResultToJson(this, toJsonT);

  factory Result.fromMapJson(Map<String, dynamic> json) {
    return Result(
      code: json['code'] as int,
      data: json['data'] as T?,
      msg: json['msg'] as String?,
      method: json['method'] as String?,
      result: json['result'] as String?,
      token: json['token'] as Token?,
    );
  }
}

@JsonSerializable()
class Token extends Object {
  String token;

  Token(
    this.token,
  );

  factory Token.fromJson(Map<String, dynamic> srcJson) =>
      _$TokenFromJson(srcJson);

  Map<String, dynamic> toJson() => _$TokenToJson(this);
}

class ResultData extends Object{

}
